#include<iostream>
auto makeCounter() {
    int count = 0;
    return [count]() mutable {
        return ++count;
        };
}

int main() {
    auto counter = makeCounter();
    std::cout << counter() << std::endl; // 1
    std::cout << counter() << std::endl; // 2
    std::cout << counter() << std::endl; // 3

    auto counter1 = makeCounter();
    std::cout << counter1() << std::endl; // 1
    std::cout << counter1() << std::endl; // 2
    std::cout << counter1() << std::endl; // 3
}
